package com.zhiwang.planet.mvvm.model


import com.rxcache.Cache
import com.zhiwang.planet.mvvm.model.entity.*
import com.zhiwang.planet.mvvm.model.entity.main.*
import com.zhiwang.planet.mvvm.model.request.*
import com.zhiwang.planet.mvvm.viewmodel.loginv2.RegisterViewModel
import io.reactivex.Observable
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.*

interface RestApi {


    @GET("before/{date}")
    fun fetchNewsBefore(@Path("date") date: String): Observable<Response<News>>

    @GET("latest")
    fun fetchLatestNews(): Observable<LatestResponse<News, TopStory>>

    //更改默认头像
    @POST("")
    fun changeDefaultAvatar(): Observable<ResponseWrapper<String>>

    //上传头像
    @POST("upload/upload_image_avatar")
    fun uploadAvatarPic(@Body body: RequestBody): Observable<ResponseWrapper<AvatarResponse>>

    //绑定支付宝账户
    @POST("ucenter_cash/bind_alipay")
    fun bindAliAccount(@Body bindAliAccountRequest: BindAliAccountRequest): Observable<ResponseWrapper<Void>>

    @POST("member/login")
    fun login(@Body loginBody: LoginRequest): Observable<ResponseWrapper<User>>

    //上传设备号
    @POST("member/get_deviceid")
    fun uploadDeviceId(@Body deviceIdRequest: DeviceIdRequest): Observable<ResponseWrapper<Void>>

    @POST("member/token_logout")
    fun logout(@Body logoutRequest: LogoutRequest): Observable<ResponseWrapper<Void>>

    @POST("advice/index")
    fun sendFeedBack(@Body feedBackRequest: FeedBackRequest): Observable<ResponseWrapper<Void>>

    @Multipart
    @POST("advice/upload_advice")
    suspend fun sendFeedBack2(@PartMap body: HashMap<String, RequestBody>): ResponseWrapper<Void>

    @HTTP(method = "GET", path = "api/app_vcode")
    fun getGraphCode(@Query("tu_token") randomStr: String, @Query("vcode_type") type: String): Observable<ResponseBody>

    @POST("api/voice")
    fun getSmsCode(@Body requestBody: SmsCodeRequest): Observable<ResponseWrapper<Void>>

    /*实际注册接口返回的json对象data字段 是个数组*/
    @POST("member/reg")
    fun register(@Body registerRequest: RegisterRequest): Observable<ResponseWrapper<List<String>>>

    @POST("appmember/reg")
    fun registerV2(@Body req: RegisterViewModel.RegReq): Observable<ResponseWrapper<String>>

    @POST("member/changepwd")
    fun changePassword(@Body changePwdRequest: ChangePasswordRequest): Observable<ResponseWrapper<Void>>

    @POST("member/findpwd")
    fun findPassword(@Body findPasswordRequest: FindPasswordRequest): Observable<ResponseWrapper<Void>>

    @POST("index")
    fun getIndexData(): Observable<ResponseWrapper<IndexData>>

    @POST("xingqiu/shouge")
    fun collectTinyDiamond(@Body idRequest: DiamondCollectRequest): Observable<ResponseWrapper<String>>

    @POST("ucenter_cash/cash_out")
    fun withdraw(@Body withDrawRequest: WithDrawRequest, @Query("api_version") version: String = "20190926"): Observable<ResponseWrapper<WithDrawBody>>

    //    @POST("ucenter_cash/lists")
    @GET("ucenter_cash/lists")
    fun getWithDrawRecord(@Query("page") page: Int /*pageRequest: PageIndexRequest*/): Observable<ResponseWrapper<WithDrawRecordBody>>

    @POST("ucenter/goldz_list")
    fun getDiamondRecord(@Body pageIndexRequest: PageIndexRequest): Observable<ResponseWrapper<ConsumptionRecordBody>>

    @POST("ucenter/goldd_list")
    fun getEnergyRecord(@Body pageIndexRequest: PageIndexRequest): Observable<ResponseWrapper<ConsumptionRecordBody>>

    @HTTP(method = "GET")
    fun downloadFile(@Url url: String): Observable<ResponseBody>

    @POST("ucenter/changepay_pwd")
    fun changePaypassword(@Body request: ChangePayPasswordRequest): Observable<ResponseWrapper<Void>>

    @POST
    fun checkApkUpdate(@Url url: String): Observable<ResponseWrapper<UpdateCheck>>
//
//    @POST("ucenter/invite_list")
//    fun getInviteInfo(): Observable<ResponseWrapper<InviteInfo>>

    @POST("ucenter/invite_info")
    fun getUserInviteInfo(@Body nonsense: NonsenseRequest): Observable<ResponseWrapper<InviteInfo>>

    @POST("ucenter_cash/cash_out")
    fun getWithDrawList(@Query("cash_type") type: String): Observable<ResponseWrapper<List<String>>>

    @FormUrlEncoded
    @POST("member/change_username")
    fun setNickName(@Field("username") nickName: String): Observable<ResponseWrapper<Void>>


    @POST("member/change_avatar")
    @FormUrlEncoded
    fun changeAvatar(@Field("id") id: String): Observable<ResponseWrapper<Void>>


    @POST("invite/app_share")
    fun getQrCode(): Observable<ResponseBody>


    @POST("invite/app_share_weixin")
    fun getShareInformation(): Observable<ResponseWrapper<ShareInformation>>

    @POST("ucenter/bind_weixin")
    fun getWxBindCodeInfo(@Body nonsenseRequest: NonsenseRequest): Observable<ResponseWrapper<WxBindCodeInfo>>


    @POST
    @FormUrlEncoded
    fun getAlipaySign(@Url url: String, @Field("arg3") userid: String, @Field("arg2") vipLevel: String,
                      @Field("pay_type") payType: String, @Field("pay_platform") payPlatform: String)
            : Observable<ResponseWrapper<String>>

    //趣钻支付vip

    @POST
    @FormUrlEncoded
    fun payByDiamond(@Url url: String, @Field("arg3") userid: String,
                     @Field("arg2") vipLevel: String,
                     @Field("pay_type") payType: String,
                     @Field("pay_platform") platform: String): Observable<ResponseWrapper<Void>>

    @POST
    @FormUrlEncoded
    fun getYesterdayRankList(@Url url: String, @Field("type") yesterday: String): Observable<ResponseWrapper<RankModel>>

    @POST
    @FormUrlEncoded
    fun getTodayRankList(@Url url: String, @Field("type") today: String): Observable<ResponseWrapper<RankModel>>

    /**
     * 获取vip信息，包括用户vip信息和所有可以开通的vip列表
     */
    @GET
    fun getVipInfo(@Url url: String): Observable<ResponseWrapper<VipModel>>

    @POST
    @FormUrlEncoded
    fun claimRankProfit(@Url url: String, @Field("nothing") nothing: String): Observable<ResponseWrapper<Void>>

    @POST
    @FormUrlEncoded
    fun getVipRecord(@Url url: String, @Field("page") page: Int): Observable<ResponseWrapper<VipRecordModel>>

    //type = 1 小说，2 头条
    @POST("yule/amuse2")
    @FormUrlEncoded
    fun postFictionReadingTime(@Field("url") url: String, @Field("times") time: Int, @Field("type") type: Int): Observable<ResponseWrapper<String>>

    @POST("yule/amuse2")
    @FormUrlEncoded
    fun postVideoClipTime(@Field("url") url: String = "defaultVideoUrl",
                          @Field("times") time: Int = 30,
                          @Field("type") type: Int = 3): Observable<ResponseWrapper<VideoClipTaskResult>>

    @POST("dshop/cj_detail")
    fun getRewardList(@Body request: PageIndexRequest): Observable<ResponseWrapper<ListReponseWrapper<Reward>>>

    @POST("dshop/cj_detail")
    fun getBonusCardList(@Body pageIndexRequest: PageIndexRequest): Observable<ResponseWrapper<ListReponseWrapper<Reward>>>

    @POST("dshop/card_detail")
    fun getKmInfo(@Body request: KmRequest): Observable<ResponseWrapper<KmInfo>>

    //    flk_detail
    @POST("dshop/flk_detail")
    fun getCardInfo(@Body request: KmRequest): Observable<ResponseWrapper<KmInfo>>

    @GET("integrawall/index_act")
    @Cache(key = "index_act", expiredTime = 10)
    fun getIndexActivities(): Observable<ResponseWrapper<IndexActivityBody>>

    @POST("mobilegames/page")
    fun getPceggPageUrl(): Observable<ResponseBody>

    @POST("ucenter/ucenter_gold")
    fun getDiamondAndBeanInfo(@Body request: NonsenseRequest): Observable<ResponseWrapper<DiamondBeanInfo>>

    @GET
    fun download(@Url url: String): Call<ResponseBody>

    @POST("ucenter/index")
    fun getServiceQQ(): Observable<ResponseWrapper<ServiceQQ>>

    @POST
    fun getGameList(@Url url: String): Observable<ResponseWrapper<List<GameItem>>>

    @POST("xingqiu/log")
    fun reportLaunchLog(@Body body: LaunchRequestBody): Observable<ResponseWrapper<Void>>

    @POST("member/bind_user_weixin")
    fun bindWxPhone(@Body req: BindWxRequest): Observable<ResponseWrapper<TokenBody>>

    @POST("ucenter/bind_phone")
    fun bindPhone(@Body req: BindPhoneRequest): Observable<ResponseWrapper<Void>>

    @GET("member/login_weixin")
    fun checkWxBind(@Query("code") code: String, @Query("deviceid") deviceId: String): Observable<ResponseWrapper<BindBody>>

    @POST("member/login_info")
    fun getUserInfo(): Observable<ResponseWrapper<User>>

    @POST("member/bind_user_weixin")
    fun createWxUser(@Body bindBody: BindWxRequest): Observable<ResponseWrapper<TokenBody>>

    @GET("yule/yule_data")
    fun getTinyGameList(): Observable<ResponseWrapper<TinyGameBody>>


    @GET("yule/yule_data")
    suspend fun getMiniGameAccount(): ResponseWrapper<MiniGameToken>


    @POST("yule/xyx_logininfo")
    fun postTinyGameAccountInfo(@Body tinyGameTokenBody: TinyGameAccountInfo): Observable<ResponseWrapper<Void>>

    @POST("yule/xyx_playinfo")
    fun postGamePlayTime(@Body body: GamePlayTimeReport): Observable<ResponseWrapper<TinyGameReward>>


    @POST("yule/xyx_playinfo")
    suspend fun postGamePlayTime2(@Body body: GamePlayTimeReport): ResponseWrapper<TinyGameReward>


    @POST("yule/xyx_token")
    fun getMiniGameTempToken(): Observable<ResponseWrapper<String>>


    @POST("yule/xyx_token")
    suspend fun getMiniGameTempToken2(): ResponseWrapper<String>

    @FormUrlEncoded
    @POST("member/login_device_check")
    fun checkDeviceEverInstalled(@Field("deviceid") deviceId: String): Observable<ResponseWrapper<DeviceQueryResult>>

    @POST("yule/check_video")
    fun checkVideoTaskCompleted(): Observable<ResponseWrapper<VideoTaskCheck>>

    /*提交 app 使用时长任务 完成状态*/
    @POST("tasks/monitor")
    fun postAppUsageTask(@Body taskIdRequest: AppUsageTaskRequest): Observable<ResponseWrapper<Void>>

    /**
     * frirnd_id:
    use_uid: 30003
    km_list: 11111111111111111111*22222222222
    22222222*33333333
     */
    @POST
    fun exchangeCards(@Url url: String, @Body welfareBody: WelfareExchange): Observable<ResponseWrapper<Void>>

    @POST
    @FormUrlEncoded
    fun verify(@Url url: String, @Field("km_list") cardNumber: String): Observable<ResponseWrapper<Void>>

    @POST
    @FormUrlEncoded
    fun transformCard(@Url url: String, @Field("km_list") cardNumber: String): Observable<ResponseWrapper<Void>>

    @POST
    @FormUrlEncoded
    fun checkUserExists(@Url url: String, @Field("frirnd_id") userId: String): Observable<ResponseWrapper<Void>>

    @POST("advice/notices")
    fun getNotifications(@Body notification: NotificationRequest): Observable<ResponseWrapper<NotificationBody>>

    @POST("advice/notices")
    fun getMessages(@Body notification: NotificationRequest): Observable<ResponseWrapper<MessageBody>>

    @POST("advice/notices_read_flag")
    fun setMessageRead(@Body req: SetReadRequest): Observable<ResponseWrapper<Int>>

    @POST("advice/notices_delete")
    fun deleteNotificationRead(@Body req: DeleteReadRequest): Observable<ResponseWrapper<NotificationBody>>

    @POST("advice/notices_delete")
    fun deleteMessageRead(@Body req: DeleteReadRequest): Observable<ResponseWrapper<MessageBody>>

    @GET("xingqiu/refresh_lists")
    fun recommendGames(): Observable<ResponseWrapper<List<HomeRecommend>>>

    @POST
    fun getImportantNotice(@Url url: String): Observable<ResponseWrapper<ImportantNotice>>

    /*娱乐页面获取游戏信息*/
    @POST("minigame/gameboard")
    fun getGame(): Observable<ResponseWrapper<EntertainBody>>

    @POST("minigame/mygame/list")
    suspend fun getMyPlayedGame(): ResponseWrapper<List<MiniGame>>

    @POST("minigame/mygame/delete")
    suspend fun deleteMyPlayedGame(@Body ids: List<String>): ResponseWrapper<List<MiniGame>>

    @POST("xingqiu/refresh_center_lists")
    fun getCenterRecommendGames(): Observable<ResponseWrapper<List<Game>>>

    @GET("advice/advice_type")
    suspend fun loadAdviceTypeList(): ResponseWrapper<List<String>>


    @GET("entertain/todayEarning")
    suspend fun loadTodayEarning(): ResponseWrapper<String>


    @POST("ucenter/update_deviceid")
    fun updateDeviceId(@Body imei: ImeiBody): Observable<ResponseWrapper<Void>>

    @POST("ucenter_cash/act_cashout")
    fun getWithdrawActivityInfo(): Observable<ResponseWrapper<WithDrawActivityInfo>>

    @POST("games/popup")
    @FormUrlEncoded
    fun getSbActivity(@Field("type") type: String = "1"): Observable<ResponseWrapper<Boolean>>


    @POST("ucenter/is_tgdaren")
    fun checkInviteMan(): Observable<ResponseWrapper<Void>>


    @POST("index")
    fun getUserInfoEx(): Observable<ResponseWrapper<IndexData>>


    @POST("member/avatar_list")
    fun getAvatarList(): Observable<ResponseWrapper<List<Avatar>>>


    @POST
    fun getExchangeList(@Url url: String): Observable<ResponseWrapper<ExchangeListBody>>

    @POST
    @FormUrlEncoded
    fun exChangeBean(@Url url: String, @FieldMap map: Map<String, String>): Observable<ResponseWrapper<Void>>


//    @POST("")
//    fun loadMobileList(): Observable<ResponseWrapper<List<TaskItemViewModel>>>


    @POST("index/ucenter_banner")
    fun loadUserCenterBanner(): Observable<ResponseWrapper<List<Banner>>>

    @POST("member/random_username")
    fun randomNickName(): Observable<ResponseWrapper<String>>

    @POST("ucenter/tidings")
    @FormUrlEncoded
    fun getActivityList(@Field("type") type: Int = 1): Observable<ResponseWrapper<List<Activity>>>

    @POST("ucenter/tidings")
    @FormUrlEncoded
    fun getSystemNotificationList(@Field("type") type: Int = 2): Observable<ResponseWrapper<List<SystemNotification>>>

    @POST("ucenter/tidings")
    @FormUrlEncoded
    fun getFeedBackList(@Field("type") type: Int = 3): Observable<ResponseWrapper<List<FeedBack>>>


    @POST("ucenter/xq_online")
    @FormUrlEncoded
    fun getFastTask(@Field("type") type: String = "kz"): Observable<ResponseWrapper<List<XqTask>>>

    @POST("ucenter/xq_online")
    @FormUrlEncoded
    fun getMobileList(@Field("type") type: String = "wy"): Observable<ResponseWrapper<List<XqTask>>>

    @POST("api/voice")
    fun getSms(@Body requestBody: SmsReq): Observable<ResponseWrapper<Void>>

    @POST("member/login_xg")
    fun loginV2(@Body req: LoginRequest): Observable<ResponseWrapper<String>>

    @POST("appmember/bind_user_weixin")
    fun bindWx(@Body bindBody: WxBindBody): Observable<ResponseWrapper<String>>

    @POST("member/change_phone")
    @FormUrlEncoded
    fun changeBindPhone(@Field("phone") phone: String, @Field("vcode") type: String): Observable<ResponseWrapper<Void>>

    @POST("appmember/login_weixin")
    fun wxLogin(@Body body: LoginRequest): Observable<ResponseWrapper<String>>


    @POST("appmember/bind_user_phone")
    fun wxBindPhone(@Body body: LoginRequest): Observable<ResponseWrapper<String>>

    @POST("appmember/index")
    fun getQQ(): Observable<ResponseWrapper<QQ>>

    @POST("appmember/is_login")
    @FormUrlEncoded
    fun getLoggedStatus(@Field("deviceid") imei: String): Observable<ResponseWrapper<Int>>

    //赚钱游戏列表
    @POST("integrawall/xiangguo_tasks")
    fun getTaskList(@Body req: TaskReq): Observable<ResponseWrapper<GameBody>>

    @POST("integrawall/xiangguo_games")
    fun getGameList(@Body req: TaskReq): Observable<ResponseWrapper<GameBody>>

    @POST("integrawall/xiangguo_games_gaofan")
    fun getGaoFanGameList(@Body req: TaskReq): Observable<ResponseWrapper<GameBody>>

    @GET("app_shandianwan/user_play_log")
    fun getH5PlayedRecord(@Query("userid") userid: String): Observable<ResponseWrapper<List<H5Record>>>


    @GET("app_shandianwan/game_list")
    fun getHotH5Game(): Observable<ResponseWrapper<List<H5HotGame>>>


    @GET("banner/yule_carousel")
    fun getYuleBanner(): Observable<ResponseWrapper<List<Banner>>>

    @POST("app_shandianwan/shiwanReward")
    fun postH5GameTime(@Body req: H5GameReq): Observable<ResponseWrapper<H5GameRes?>>


    @POST("ucenter_qdexchange/exchange")
    fun checkExchangeEnable(): Observable<ResponseWrapper<Void>>

}